import java.util.Scanner;

public class Demo3 {
	String name;
	int age;

	public void buy() {
		String answer = null;
		Scanner input = new Scanner(System.in);
		do {
			System.out.println("请输入游客姓名：");
			this.name = input.next();
			System.out.println("请输入游客年龄：");
			this.age = input.nextInt();
			if (this.age >= 18 && this.age <= 60) {
				System.out.println(this.name + "的年龄为" + this.age + "岁，门票价格为20元");
			} else {
				System.out.println(this.name + "的年龄为" + this.age + "岁，门票价格为免费");
			}
			System.out.println("您需要继续购票吗？(y/n):");
			answer = input.next();
			if ("n".contentEquals(answer)) {
				break;
			}
		} while (true);
		System.out.println("退出程序");
	}

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		Demo3 tom = new Demo3();
		tom.buy();
	}
}
